package com.Lgwd.controller.monsterController;


import com.Lgwd.dao.UserDao;
import com.Lgwd.entity.MonsterEntiy;

import com.Lgwd.service.monsterService.MonsterService;
import com.Lgwd.utils.ResponseData;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Slf4j
@RestController
@CrossOrigin
public class MonsterCurdController {


    @Autowired
    MonsterService monsterService;


    /**
     * 新增怪物
     *
     * @return
     */
    @GetMapping("/addMonster")
    public ResponseData addMonster() {
        monsterService.addMonster();

        return ResponseData.defaultSuccess();
    }

    /**
     * 根据角色等级来生成怪物（范围取值    获取到的信息 作用于前段视图
     */

    @PostMapping("/getMonsterByUserLv")
    public ResponseData getMonsterByUserLv(@RequestBody UserDao userDao) {

        MonsterEntiy monsterEntiy = monsterService.getMonsterByUserLv(userDao.getLv());
        log.info("【返回的怪物等级："+monsterEntiy.getMonster_lv()+"】"+"【怪物HP："+monsterEntiy.getMonster_HP()+"】");
        if(monsterEntiy==null){
            return  ResponseData.defaultFail("未获取到怪物信息");
        }
        return ResponseData.defaultSuccess(monsterEntiy);
    }

}
